
/**
 * Filters for packets where the "to" field contains a specified value. For example,
 * the filter could be used to listen for all packets sent to a group chat nickname.
 *
 * @author Matt Tucker
 */
class ToContainsFilter : public PacketFilter {
public: 

    /**
     * Creates a "to" contains filter using the "to" field part.
     *
     * @param to the to field value the packet must contain.
     */
    ToContainsFilter(std::string & to) : to(to) {}

    bool accept(Packet * packet) {
        if (packet->getTo().empty()) {
            return false;
        }
        else {
			std::string addr = packet->getTo();
			std::transform(addr.begin(), addr.end(), addr.begin(), ::tolower);

			return from.find(address) != std::npos;
        }
    }
private:
	std::string to;
};
